package com.xhdd.view;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xhdd.bean.Chapter;

public class ChapterListAdapter extends BaseAdapter {

	private List<Chapter> chapters = null;
	private Context mContext;
	public ChapterListAdapter(Context context) {
		mContext=context;
	}
	public void setChapters(List<Chapter> list) {
		this.chapters = list;
	}

	@Override
	public int getCount() {
		if (chapters != null) {
			return chapters.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int position) {
		if (chapters != null) {
			return chapters.get(position);
		}
		return null;
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView textView = null;
		if (convertView != null) {
			textView = (TextView) convertView;
		} else {
			textView=new TextView(mContext);
		}
		textView.setTextColor(Color.WHITE);
		textView.setTextSize(20);
		textView.setText(chapters.get(position).getTitle());
		textView.setPadding(0, 15, 0, 15);
		return textView;
	}

	
}
